var wxApi = {
    CONSTANTS:{
        wxApiSignUrl:"wechat/getSign.php?account=meface&callback=wxApi.wxConfig&url=" + encodeURIComponent(location.href.split("#")[0]),
        wxApiJSUrl:"//res.wx.qq.com/open/js/jweixin-1.3.2.js"
    },
    getScript:function(b) {
        var a = document.createElement("script");
        a.type = "text/javascript";
        a.src = b.url;
        a.charset = b.charset || "UTF-8";
        a.onload = a.onreadystatechange = function() {
            if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
                this.onload = this.onreadystatechange = null;
                b.callback && b.callback();
            }
        };
        document.getElementsByTagName("head")[0].appendChild(a);
    },
    wxConfig:function(a) {
        wx.config({
            debug:false,
            appId:a.appId,
            timestamp:a.timestamp,
            nonceStr:a.nonceStr,
            signature:a.signature,
            jsApiList:[ 
                "checkJsApi",
                "chooseImage",
                "previewImage",
                "uploadImage",
                "downloadImage",
                "getLocation",
                "chooseWXPay",
                "onMenuShareTimeline", 
                "onMenuShareAppMessage", 
                "hideOptionMenu" 
            ]
        });
        console.log(a)
    },
    init:function(b) {
        if (navigator.userAgent.toLowerCase().match(/micromessenger/i) != "micromessenger") {
            return;
        }
        
        var c = this;
        c.getScript({
            url:this.CONSTANTS.wxApiJSUrl,
            callback:function() {

                c.getScript({
                    url:c.CONSTANTS.wxApiSignUrl,
                    callback:function() {
                        console.log(c.CONSTANTS.wxApiSignUrl)
                        b && b();
                        wx.ready(function() {
                            wxShare()
                        });
                        wx.error(function(d) {});
                    }
                });
                
            }
        });
    }
};